From 2468538da26132dd7342872851de9210accb5de6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=98yvind=20Kol=C3=A5s?= Date: Sun, 8 Apr 2018 13:05:10 +0200 Subject: [PATCH] tools: add html variant of path matrix --- tools/babl_fish_path_fitness.c | 87 +++++++++++++++++++++++++++------- 1 file changed, 70 insertions(+), 17 deletions(-) diff --git a/tools/babl_fish_path_fitness.c b/tools/babl_fish_path_fitness.c index 93e1287..d56ca05 100644 --- a/tools/babl_fish_path_fitness.c +++ b/tools/babl_fish_path_fitness.c @@ -11,26 +11,45 @@ #define random rand #endif -#define pixels 1024 int total_length = 0; int total_cost = 0; int total = 0; int ok = 0; -static double test[pixels * 4]; - -static void -test_init (void) -{ - int i; +static int qux = 0; - for (i = 0; i < pixels * 4; i++) - test [i] = (double) random () / RAND_MAX; -} +#define UTF8 -static int qux = 0; +#ifdef UTF8 static char *utf8_bar[] = { " ", "·", "▁", "▂", "▃", "▄", "▅", "▆", "▇", "█" }; +#define DIRECT " " +#define SELF " " +#define EMPTY " " +#define SL "" +#define NL "\n" + +#else + + +static char *utf8_bar[] = { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " "}; +#define SL "
" +#define SELF " " +#define EMPTY " " +#define NL "
\n" + +#endif + + + /* static char *utf8_bar[]= {"!","▁","▃","▅","▇","█","!","!","!"}; static char *utf8_bar[]={"·", "█", "▇", "▆", "▅", "▄", "▃", "▂", "▁", }; @@ -43,9 +62,8 @@ static int destination_each (Babl *babl, Babl *source = userdata; Babl *destination = babl; - qux++; if (qux % babl_formats_count () == qux / babl_formats_count ()) - printf (" "); + printf (SELF); else { Babl *temp = babl_fish_path (source, destination); @@ -60,10 +78,11 @@ static int destination_each (Babl *babl, } else { - printf (" "); + printf (EMPTY); total++; } } + qux++; return 0; } @@ -72,19 +91,51 @@ static int source_no = 0; static int source_each (Babl *babl, void *userdata) { + printf (SL); babl_format_class_for_each (destination_each, babl); - printf ("──%2i %s\n", source_no++, babl->instance.name); +#ifdef UTF8 + printf ("──%2i %s%s", source_no++, babl->instance.name, NL); +#else + printf ("%2i:%s%s", source_no++, babl->instance.name, NL); +#endif return 0; } int main (void) { babl_init (); - test_init (); babl_set_extender (babl_extension_quiet_log ()); + +#ifndef UTF8 + printf ("\n"); + printf ("\n"); + + printf ("\n"); + printf ("\n"); + +#endif + babl_format_class_for_each (source_each, NULL); +#ifdef UTF8 { int i; @@ -112,7 +163,6 @@ int main (void) } printf ("\n"); - /* for (i = 0; i < babl_formats_count (); i++) printf ("│"); @@ -140,6 +190,9 @@ int main (void) printf ("total cost : %i\n", total_cost); /*printf ("ok / total : %i %i %f\n", ok, total, (1.0*ok) / total); */ +#else + printf ("\n"); +#endif babl_exit (); -- 2.30.2